Caching Cryptographic Materials
This feature allows you to create a caching materials manager that caches cryptographic materials for a specified duration, number of bytes, or number of messages. This reduces the number of calls to AWS KMS, improving performance.
const { NodeCachingMaterialsManager } = require('@aws-crypto/caching-materials-manager-node');
const { KmsKeyringNode } = require('@aws-crypto/kms-keyring-node');
const keyring = new KmsKeyringNode({
generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd1234-abcd-1234-abcd-1234abcd1234',
keyIds: ['arn:aws:kms:us-west-2:123456789012:key/abcd1234-abcd-1234-abcd-1234abcd1234']
});
const cachingCMM = new NodeCachingMaterialsManager({
backingMaterials: keyring,
maxAge: 300000, // 5 minutes
maxBytesEncrypted: 1000000, // 1MB
maxMessagesEncrypted: 1000
});
console.log('Caching Materials Manager created:', cachingCMM);